/**
 * 执行 {{logicNode.name}} 节点
 *
 * @protected
 * @memberof {{pascalCase uiLogic.codeName}}UILogicBase
 */
protected async execute_{{logicNode.codeName}}_node() {
{{#if (and logicNode.dstPSDEUILogicParam (and logicNode.dstPSAppDataEntity logicNode.dstPSAppDEAction))}}
    {{#if (or logicNode.dstPSDEUILogicParam.entityListParam logicNode.dstPSDEUILogicParam.entityParam)}}
    try {
        const dstParam = this.getParam("{{logicNode.dstPSDEUILogicParam.codeName}}");
        if (dstParam) {
            const service = await App.getDataService("{{logicNode.dstPSAppDataEntity.codeName}}", this.context);
            if (service && service["{{logicNode.dstPSAppDEAction.codeName}}"] && service["{{logicNode.dstPSAppDEAction.codeName}}"] instanceof Function) {
                const getTempContext = (data: IParam) => {
                    const tempContext = deepCopy(this.context);
                    if (data) {
                        Object.assign(tempContext, data);
                    }
                    return tempContext;
                }
                {{#if logicNode.dstPSDEUILogicParam.entityParam}}
                const tempContext = getTempContext(dstParam.getReal());
                const res = await service["{{logicNode.dstPSAppDEAction.codeName}}"](tempContext, dstParam.getReal() ? dstParam.getReal() : {});
                if (res.success && res.data) {
                    {{#if logicNode.retPSDEUILogicParam}}
                    const retParam = this.getParam("{{logicNode.retPSDEUILogicParam.codeName}}");
                    if (retParam) {
                        retParam.bind(res.data);
                    }
                    {{/if}}
                    this.bindLastReturnParam(res.data);
                } else {
                    throw new Error(`执行实体行为失败`);
                }
                {{else}}
                // 数据对象列表类型
                if (dstParam.getReal() && (dstParam.getReal().length > 0)) {
                    if (dstParam.getReal().length > 20) {
                        throw new Error(`操作数据量超过20条，建议使用后台处理逻辑`);
                    }
                    let promises: any[] = [];
                    dstParam.getReal().forEach((item: any) => {
                        const tempContext = getTempContext(item);
                        promises.push( service["{{logicNode.dstPSAppDEAction.codeName}}"](tempContext, item ? item : {}));
                    })
                    const resArray = await Promise.all(promises);
                    if (resArray && resArray.length > 0) {
                        const resultArray: any[] = [];
                        resArray.forEach((res: any) => {
                            if (result.success && result.data) {
                                resultArray.push(res.data);
                            }
                        })
                        {{#if logicNode.retPSDEUILogicParam}}
                        const retParam = this.getParam("{{logicNode.retPSDEUILogicParam.codeName}}");
                        if (retParam) {
                            retParam.bind(resultArray);
                        }
                        {{/if}}
                        this.bindLastReturnParam(resultArray);
                    } else {
                        throw new Error(`执行实体行为失败`);
                    }
                } else {
                    {{#if logicNode.retPSDEUILogicParam}}
                    const retParam = this.getParam("{{logicNode.retPSDEUILogicParam.codeName}}");
                    if (retParam) {
                        retParam.bind([]);
                    }
                    {{/if}}
                    this.bindLastReturnParam([]);
                }
                {{/if}}
            }
        } else {
            throw new Error(`操作参数缺失！`);
        }
        {{> @macro/logic-node/next-node.hbs}}
    } catch (error: any) {
        throw new Error(`执行 {{logicNode.name}} 节点 ${error && error.message ? error.message : '发生未知错误！'}`);
    }
    {{else}}
    throw new Error(`实体行为操作参数只能为数据对象变量类型或者数据对象列表类型`);
    {{/if}}
{{else}}
    throw new Error(`操作参数缺失！`);
{{/if}}
}
